/** @file lable.cpp
 */
#include "lable.h"
#include "string.h"
#include "stdio.h"

//#include "gdi.h"

Lable::Lable(HWND parent, char *text):Widget(parent)
{
    activable =0;
    name =(char*)"Lable";

    font =font_STANDARD;
    this->text =text;
    rect.x1 =rect.x0 + strlen(text) * (FONT_WIDTH(font)  +1);
    rect.y1 =rect.y0 + font->height;
}

Lable::~Lable()
{
}

void Lable::setupWidgets()
{
}

void Lable::setText( char *text)
{
    this->text =text;
    rect.x1 =rect.x0 + strlen(text) *(FONT_WIDTH(font) +1);
    rect.y1 =rect.y0 + font->height;
    draw(&rect);
}

void Lable::setFont(FONT *font)
{
    this->font =font;
    rect.x1 =rect.x0 + strlen(text) *(FONT_WIDTH(font) +1);
    rect.y1 =rect.y0 + font->height;
}

void Lable::draw(Rect *r)
{
    pDC->drawString(rect.x0,rect.y0, rect.x1,rect.y1, text, 0x0F, 0x00,font_STANDARD);   

    pDC->dirty(max(r->x0,rect.x0), max(r->y0,rect.y0), min(r->x1,rect.x1), min(r->y1,rect.y1));

    Widget::draw(r);
}

/** @function eventHandler
 *  @brief    Lable widget event handler
 */
int Lable::eventHandler(HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)
{
    return Widget::eventHandler(hWnd, iMsg, wParam, lParam);
}

